<?php

namespace App\Http\Model;



use App\Http\Models\BundleGoods;

class UserCart extends Base
{
    /**
     * 定义数据库表名
     *
     * @var string
     */
    protected $table = 'user_cart';

    /**
     * 定义主键名
     *
     * @var string
     */
    protected $primaryKey = 'cart_id';

    protected $fillable = [
        "user_id",
        "goods_id",
        "sku_id",
        "count",
        "price",
        "total_price",
        "seesion",
        "point",
        "total_point",
        "bundle_id",
        "cart_type",
    ];
    

    public function user()
    {
        return $this->belongsTo(Users::class, 'user_id', 'user_id');
    }

    public function goods()
    {
        return $this->belongsTo(Goods::class, 'goods_id', 'goods_id');
    }

    public function sku()
    {
        return $this->belongsTo(GoodsSku::class, 'sku_id', 'sku_id');
    }

    public function bundle()
    {
        return $this->belongsTo(Bundle::class, 'bundle_id', 'id');
    }

    public function bundleGoods()
    {
        return $this->hasMany(BundleGoods::class, 'bundle_id', 'bundle_id');
    }

}
